cmake_minimum_required(VERSION 3.2)

file(GLOB BOLT_CONFIGURE_FILE $ENV{BOLT_ROOT}/bolt.cmake ${BOLT_ROOT}/bolt.cmake)
if (BOLT_CONFIGURE_FILE)
    include(${BOLT_CONFIGURE_FILE})
else (BOLT_CONFIGURE_FILE)
    message(FATAL_ERROR "
FATAL: can not find bolt.cmake in <BOLT_ROOT> directory,
       please set shell or cmake environment variable BOLT_ROOT.
    ")
endif (BOLT_CONFIGURE_FILE)

project(tests)

set_policy()

SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${BOLT_ROOT}/cmakes")
find_package(Uni)
find_package(Image)
find_package(TensorComputing)
find_package(Inference)
find_package(jpeg)
if(USE_MALI)
    find_package(Gcl)
endif(USE_MALI)

set_project_install_directory()
set_c_cxx_flags()
set_test_c_cxx_flags()

if (BUILD_TEST)
    if (USE_NEON)
        blas_enhance(test_mmm)
        blas_enhance(test_mvm)
        tensor_computing(test_activation)
        tensor_computing(test_attention)
        tensor_computing(test_clip)
        tensor_computing(test_concat)
        tensor_computing(test_convolution)
        tensor_computing(test_deconvolution)
        tensor_computing(test_depthwise_convolution)
        tensor_computing(test_dilated_convolution)
        tensor_computing(test_detectionoutput)
        tensor_computing(test_eltwise)
        tensor_computing(test_fully_connected)
        tensor_computing(test_lstm)
        tensor_computing(test_multiply)
        tensor_computing(test_reduction)
        tensor_computing(test_pooling)
        tensor_computing(test_priorbox)
        tensor_computing(test_reshape)
        tensor_computing(test_softmax)
        tensor_computing(test_split)
        tensor_computing(test_slice)
        tensor_computing(test_scale)
        tensor_computing(test_transpose)
        
        if (USE_INT8)
            blas_enhance(test_mmm_int8)
            blas_enhance(test_mvm_int8)
            tensor_computing(test_convolution_int8)
            tensor_computing(test_depthwise_convolution_int8)
            tensor_computing(test_concat_int8)
            tensor_computing(test_pooling_int8)
        endif(USE_INT8)
        
        if (USE_FP16)
            tensor_computing(test_convolution_bnn)
        endif(USE_FP16)
    endif (USE_NEON)
    
    image(test_image_processing)
    image(test_image_resize)

    inference(test_api_c test_api_c.c)
    if (USE_MALI)
        if (USE_FP16)
            inference(test_pipeline_ocl test_pipeline_ocl.cpp)
            inference(test_convolution_ocl test_convolution_ocl.cpp)
            inference(test_depthwise_convolution_ocl test_depthwise_convolution_ocl.cpp)
            inference(test_fully_connected_ocl test_fully_connected_ocl.cpp)
        endif (USE_FP16)
    endif (USE_MALI)
endif (BUILD_TEST)
